﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using QLPMT_DTO;

namespace QLPMT_DAO
{
   public class ThamSoDAO
    {
       DataProvider provider;
       public ThamSoDAO()
       {
           provider = new DataProvider();
       }
       // lay so luong benh nhan toi da
       public ThamSo GetThamSo()
       {
           provider.Connect();
           string sql = "select * from THAMSO";
           SqlDataReader reader = provider.ExecuteReader(sql);
           reader.Read();
           int benhnhantoida= reader.GetInt32(0);
           double tienkham = (double)reader.GetInt32(1);
           ThamSo dto = new ThamSo(benhnhantoida,tienkham);
           return dto;
       }
        // Cập Nhật lại qui dinh
       public void CapNhatQuiDinh(ThamSo dto)
       {
           provider.Connect();
           string sql = "Update ThamSo set SoLuongBenhNhanToiDa=" + dto.Soluongbenhnhantoida + ", TienKham=" + dto.Tienkham + " where TienKham <> -1";
           provider.ExecuteQuery(sql);
           provider.Disconnect();
       }
    }
}
